﻿<div>

    <script type="text/javascript">
        $(function () {
            $("#btn1").click(function () {
                $("#t2").codemirror("enable");
            });

            $("#btn2").click(function () {
                $("#t2").codemirror("disable");
            });

            $("#btn3").click(function () {
                alert($("#t2").codemirror("getValue"));
            });

            $("#btn4").click(function () {
                $("#t2").codemirror("setValue", "abcd");
            });

            $("#btn5").click(function () {
                $("#t2").codemirror("reset");
            });

            $("#btn6").click(function () {
                $("#t2").codemirror("focus");
            });

            $("#btn7").click(function () {
                $("#t2").codemirror("clear");
            });

            $("#btn8").click(function () {
                $("#t2").codemirror("refresh", "ajaxError/demo.html");
            });

            $("#btn9").click(function () {
                $("#t2").codemirror("resize", { width: 900, height: 500 });
            });

            $("#btn21").click(function () {
                $("#t2").codemirror("destroy");
            });

            $("#btn22").click(function () {
                $("#t2").codemirror("show");
            });

            $("#btn23").click(function () {
                $("#t2").codemirror("hide");
            });

            $("#btn24").click(function () {
                $("#t2").codemirror("undo");
            });

            $("#btn25").click(function () {
                $("#t2").codemirror("redo");
            });

            $("#btn26").click(function () {
                alert($("#t2").codemirror("getSelection"));
            });


            $("#btn41").click(function () {
                $("#t2").codemirror("validate");
            });

            $("#btn42").click(function () {
                $("#demo").form("validate");
            });

            $("#btn43").click(function () {
                $("#demo").form("enableValidation");
            });

            $("#btn44").click(function () {
                $("#demo").form("disableValidation");
            });

            $("#btn45").click(function () {
                $("#demo").form("clear");
            });

            $("#btn46").click(function () {
                $("#demo").form("reset");
            });

            $("#btn47").click(function () {
                $("#demo").form("load", {
                    t2: "111"
                });
            });



            $("#btn51").click(function () {
                $.easyui.showOption($(this).currentPanel().form("getData"));
            });
        });
    </script>
    <style>
    </style>

    <h2>jEasyUI CodeMirror Extensions</h2>
    <p>该部分扩展由文件 jquery.codemirror.js 实现。</p>
    <hr />
    <input id="btn1" type="button" value="enable" />
    <input id="btn2" type="button" value="disable" />
    <input id="btn3" type="button" value="getValue" />
    <input id="btn4" type="button" value="setValue" />
    <input id="btn5" type="button" value="reset" />
    <input id="btn6" type="button" value="focus" />
    <input id="btn7" type="button" value="clear" />
    <input id="btn8" type="button" value="refresh" />
    <input id="btn9" type="button" value="resize(900, 500)" />
    <hr />
    <input id="btn21" type="button" value="destroy" />
    <input id="btn22" type="button" value="show" />
    <input id="btn23" type="button" value="hide" />
    <input id="btn24" type="button" value="undo" />
    <input id="btn25" type="button" value="redo" />
    <input id="btn26" type="button" value="getSelection" />
    <hr />
    <input id="btn41" type="button" value="validate" />
    <input id="btn42" type="button" value="validate-form" />
    <input id="btn43" type="button" value="enableValidation-form" />
    <input id="btn44" type="button" value="disableValidation-form" />
    <input id="btn45" type="button" value="clear-form" />
    <input id="btn46" type="button" value="reset-form" />
    <input id="btn47" type="button" value="load-form" />
    <hr />
    <input id="btn51" type="button" value="getData-form" />
    <hr />
    <textarea id="t2" name="t2" class="easyui-codemirror" data-options="
              mode: 'text/html',
              lineNumbers: true, width: 800, height: 400, fontSize: '14px',
              value: '123',
              required: true,
              ">
        <script type="text/javascript">
            $(function () {
                var editor = CodeMirror.fromTextArea($("#t1")[0], {
                    lineNumbers: true,
                    mode: "text/html",
                    readOnly: "nocursor"
                });

                $("#btn1").click(function () {
                    editor.execCommand("selectAll");
                });
            });
        </script>
    </textarea>

</div>